package com.nike.amoeba.api

import com.nike.amoeba.bean.BaseListBean
import com.nike.amoeba.bean.BaseResponseBean
import com.nike.amoeba.bean.DataBean
import com.nike.amoeba.bean.db.TaskAssetBean
import com.nike.amoeba.bean.db.TaskStockBean
import com.nike.amoeba.util.CacheUtil
import okhttp3.ResponseBody
import retrofit2.http.*


/**
 * Created by xuhao on 2017/11/16.
 * Api 接口
 */

interface ApiService{

    companion object {

        private val url =
//            "192.168.2.28"
            "47.243.120.137"

//        var SERVLET_URL = "http://" +
//                url + "/RFIDInventory_V2.0.0/RFIDInventoryWebService/"

        var SERVLET_URL = "http://" +
                url + "/RFIDInventoryWebServiceV2/"

        private const val asmx = "MobileWebService.asmx/"
    }

    //登录
    @FormUrlEncoded
    @POST("$asmx" + "CheckLogin")
    suspend fun CheckLogin(
        @Field("companyID") companyID: String,
        @Field("loginID") loginID: String,
        @Field("userPwd") userPwd: String
    ): BaseResponseBean<DataBean>

    //仓库盘点
    @FormUrlEncoded
    @POST("$asmx" + "getStockTakeList")
    suspend fun getStockTakeList(
        @Field("CpCode") CpCode: String?,
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyID") companyid: String  = CacheUtil.getCompanyID()
    ): BaseListBean<ArrayList<TaskStockBean>>


    //仓库盘点列表
    @FormUrlEncoded
    @POST("$asmx" + "getStockTakeDetail")
    suspend fun getStockTakeDetail(
        @Field("OrderNo") orderno: String,
        @Field("CpCode") code: String,
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyID") companyid: String  = CacheUtil.getCompanyID()
    ): ResponseBody

    //盘点列表
    @FormUrlEncoded
    @POST("$asmx" + "stockTakeList")
    suspend fun stockTakeList(
        @Field("CpCode") CpCode: String?,
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID(),
    ): BaseListBean<ArrayList<TaskAssetBean>>

    //模组化
    @FormUrlEncoded
    @POST("$asmx" + "getModuleList")
    suspend fun getModuleList(
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): BaseResponseBean<DataBean>

    // Rfid列表
    @FormUrlEncoded
    @POST("$asmx" + "stockTakeListAsset")
    suspend fun stockTakeListAsset(
        @Field("orderno") orderno: String,
        @Field("CpCode") CpCode: String,
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): ResponseBody

    // 库存调整列表
    @FormUrlEncoded
    @POST("$asmx" + "getInventoryList")
    suspend fun getInventoryList(
        @Field("CpCode") code: String?,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID(),
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        ): ResponseBody

    // 库存调整详细列表
    @FormUrlEncoded
    @POST("$asmx" + "getInventoryDetail")
    suspend fun getInventoryDetail(
        @Field("CpCode") code: String,
        @Field("ARoNo") ARoNo: String,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): BaseListBean<ArrayList<DataBean>>

    // 入库
    @FormUrlEncoded
    @POST("$asmx" + "getWarehouseList")
    suspend fun getWarehouseList(
        @Field("CpCode") code: String?,
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): BaseListBean<ArrayList<DataBean>>

    // 出库
    @FormUrlEncoded
    @POST("$asmx" + "getOutWarehouseList")
    suspend fun getOutWarehouseList(
        @Field("CpCode") code: String?,
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): BaseListBean<ArrayList<DataBean>>

    // 创建单详情
    @FormUrlEncoded
    @POST("$asmx" + "getInboundOrderDetail")
    suspend fun getInboundOrderDetail(
        @Field("BatchNo") BatchNo: String?,
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): BaseResponseBean<DataBean>

    // 出库创建单详情
    @FormUrlEncoded
    @POST("$asmx" + "getOutboundOrderDetail")
    suspend fun getOutboundOrderDetail(
        @Field("BatchNo") BatchNo: String?,
        @Field("CpCode") code: String?,
        @Field("UNRoNo") userid: String = "",
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): ResponseBody

    // 入库创建单详情
    @FormUrlEncoded
    @POST("$asmx" + "getInboundOrderDetail")
    suspend fun getInboundOrderDetail2(
        @Field("BatchNo") BatchNo: String?,
        @Field("CpCode") code: String?,
        @Field("UNRoNo") userid: String = "",
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): ResponseBody

    // 上传出库
    @FormUrlEncoded
    @POST("$asmx" + "UpdateOutbound")
    suspend fun UpdateOutbound(
        @Field("strJson") strJson: String?,
        @Field("BatchNo") BatchNo: String?,
        @Field("CpCode") code: String?,
        @Field("URoNo") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): BaseResponseBean<String>

    // 上传库存调整
    @FormUrlEncoded
    @POST("$asmx" + "UpdateInventory")
    suspend fun UpdateInventory(
        @Field("CpCode") code: String?,
        @Field("strJson") strJson: String?,
        @Field("URoNo") RoNo: String?,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): BaseResponseBean<String>

    // 上传入库
    @FormUrlEncoded
    @POST("$asmx" + "UpdateInbound")
    suspend fun UpdateInbound(
        @Field("strJson") strJson: String?,
        @Field("BatchNo") BatchNo: String?,
        @Field("CpCode") code: String?,
        @Field("URoNo") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): BaseResponseBean<String>

    // 出库单详情里面的EPC
    @FormUrlEncoded
    @POST("$asmx" + "getOutboundPrint")
    suspend fun getOutboundPrint(
        @Field("BatchNo") BatchNo: String?,
        @Field("ARoNo") ARoNo: String?,
        @Field("URoNo") UNRoNo: String,
        @Field("CpCode") code: String?,
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): BaseResponseBean<DataBean>

    // 入库单详情里面的EPC
    @FormUrlEncoded
    @POST("$asmx" + "getInboundPrint")
    suspend fun getInboundPrint(
        @Field("BatchNo") BatchNo: String?,
        @Field("ARoNo") ARoNo: String?,
        @Field("URoNo") UNRoNo: String,
        @Field("CpCode") code: String?,
        @Field("userid") userid: String = CacheUtil.getUser()!!.RoNo,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): BaseResponseBean<DataBean>

    //上传图片
    @Headers("Content-Type: application/x-www-form-urlencoded")
    @FormUrlEncoded
    @POST("$asmx" + "UploadStockTake")
    suspend fun FileToByte(
        @Field("CpCode") code: String?,
        @Field("companyID") UnitCode: String?,
        @Field("strJson") strJson: String
    ): BaseResponseBean<DataBean>

    //库存EPC上传
    @FormUrlEncoded
    @POST("$asmx" + "UpdateStockTake")
    suspend fun UpdateStockTake(
        @Field("CpCode") code: String?,
        @Field("OrderNo") OrderNo: String?,
        @Field("strJson") strJson: String,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID(),
        @Field("URoNo") userid: String = CacheUtil.getUser()!!.RoNo,
    ): BaseResponseBean<DataBean>

}